package eventbus

import (
	"context"
	"time"

	"github.com/gin-gonic/gin"
)

type EventData struct {
	Data interface{}
}

type EventDataChannel chan *EventData

func (e EventDataChannel) Data(timetout time.Duration) interface{} {
	ctx, cancle := context.WithTimeout(context.Background(), timetout)
	defer cancle()
	select {
	case <-ctx.Done():
		return gin.H{"message": "timetout"}
	case data := <-e:
		return data
	}
}
